import { CouData, CouponData } from '../../network/api/coupon/index'
// pages/coupon/coupon.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		navList: [],
		showList: [
			{ name: "可领", id: 1, },
			{ name: "已领", id: 2, },
			{ name: "失效", id: 3, },
			{ name: "口令", id: 4, },
		],
		activeIndex: 0,
		showLq: false,
		qValue: ''
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
		CouponData().then(res => {
			let arr = res.data.filter(item => {
				return item.showInFront
			})
			this.setData({
				navList: arr
			})
		})
	},
	// 切换tab
	couTap (e) {
		this.setData({
			activeIndex: e.target.dataset.i
		})
	},
	// 打开领取弹窗
	goLq (e) {
		console.log(e.target)
		// console.log(item1.target.dataset.item.showInFront)
		this.setData({
			showLq: true
			// item1.target.dataset.item.showInFront:false
			// e.target.dataset.item1.showInFront = !showInFront
		})
	},
	// 点击取消领取
	hide (e) {
		if (e.target.dataset.flag) {
			this.setData({
				showLq: false
			})
		}
	},
	// 输入框input事件
	changeValue (e) {
		console.log(e.detail.value)
		this.setData({
			qValve: e.detail.value
		})
	},
	// 领取优惠券
	receive (qValue) {
		CouData().then(res => {
			console.log(res)
		})
	},
})